<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<!-- jqgrid-->
<link
	href="${basePath}/css/plugins/jqgriddemo/css/ui.jqgrid-bootstrap.min.css"
	rel="stylesheet" />
<!doctype html>
<html>
<head>
<style type="text/css">
* {
	margin: 0px;
	padding: 0px;
	font-size: 12px;
}

.laydate-icon {
	height: 20px;
}
</style>
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="iboxtitle">
			<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;财务相关>垫提车款</span>
		</div>
		<div class="ibox-content ibox-zxsearchqu ">
			<div class="row">
				<div class="col-xs-12 col-sm-12 col-md-12 col-lg-4">
					<div class="row">
						<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
							 <input type="text" placeholder="客户名" id="customerName" name="customerName" class="form-control">
						</div>
						<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
							 <input type="text" placeholder="业务员" id="salesmanName" name="salesmanName" class="form-control">
						</div>
					</div>
				</div>
				<div class="col-xs-12 col-sm-12 col-md-12 col-lg-4">
					<div class="row">
						<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
							<input id="createOrderTimeStartDate" name="createOrderTimeStartDate" placeholder="开始时间" class="laydate-icon form-control">
						</div>
						<label class="hxleft">至</label>
						<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
							<input id="createOrderTimeEndDate" name="createOrderTimeEndDate" placeholder="结束时间" class="laydate-icon form-control">
						</div>
					</div>
				</div>
				<div class="col-xs-12 col-sm-12 col-md-12 col-lg-4">
					<button class="btn dpbtn_blue_null" type="button" onclick="query(0,0);">当日</button>
					<button class="btn dpbtn_blue_null" type="button" onclick="query(-1,-1);">昨日</button>
					<button class="btn dpbtn_blue_null" type="button" onclick="query(-6,0);">近7日</button>
					<button class="zhixcx" type="button" onclick="query();">执行查询</button>
				</div>
			</div>
		</div>
		<div class="ibox-content">
			<span class="warning-label"><span class="red-dp-circle"></span>完成财务一审核的小额订单信息或者完成财务二审核的大额订单信息</span>	
			<div class="jqGrid_wrapper">
				<table id="table_list_1"></table>
				<div id="pager_list_1"></div>
			</div>
		</div>
	</div>


	<!-- public quote -->
	<%@include file="/jsp/comm_js_include.jsp"%>
	<!-- jqGrid -->
	<script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/jquery.jqGrid.min.js"></script>
	<script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/grid.locale-cn.min.js"></script>

	<!-- layerDate plugin javascript -->
	<script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>


	<!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
	<script type="text/javascript">
	    
	    var winWidth = $(window).width();
		var winHeight = $(window).height();
		
	    jQuery(function($) {  
	    	
	    	var start = {
	    			  elem: '#createOrderTimeStartDate', 
	  		          event: 'focus' ,
	    			  format: 'YYYY-MM-DD',
	    			  max: '2099-06-16', //最大日期
	    			  istime: true,
	    			  istoday: false,
	    			  choose: function(datas){
	    			     end.min = datas; //开始日选好后，重置结束日的最小日期
	    			     end.start = datas; //将结束日的初始值设定为开始日
	    			  }
	    			};
	    	
	    	var end = {
	    			  elem: '#createOrderTimeEndDate', 
	  		          event: 'focus' ,
	    			  format: 'YYYY-MM-DD',
	    			  max: '2099-06-16',
	    			  istime: true,
	    			  istoday: false,
	    			  choose: function(datas){
	    			    start.max = datas; //结束日选好后，重置开始日的最大日期
	    			  }
	    			};
	    	
	    	laydate(start);
	    	laydate(end);
	    	getData();
	    });
	    
	    var getData = function()
	    {
	  var winWidth = $('div.ibox-content').width();
	        var winHeight = document.body.offsetHeight - 330;
	     	var win = winWidth / 7 - 20;
  	 	   $.jgrid.defaults.styleUI = 'Bootstrap';
  	 	   
		  jQuery("#table_list_1").jqGrid
		  ({
			url:'${basePath}/CwRemitCarController/remitCarList',
	        datatype : "json",
	        colNames : [ '主键','订单生成时间','风控过审时间','客户名称','身份证号码','贷款额','订单类型', '经销商','经销商等级', '部门','业务员', '银行'],
	        /* colNames : [ '主键', '风控过审时间', '客户名称','身份证号码','贷款额','订单类型', '经销商','经销商等级', '部门','业务员', '银行'], */
	        colModel : [ 
	                     {name: 'replaceId', index: 'B.id', hidden:true},
	                     {name: 'orderCreated',index: 'B.created',width: win,align: "center", formatter:function(a) {
	                    	 return formateIntegerMinutes(a);
	                     }},
	                     {name: 'timeAuditFinish',index: 'B.timeAuditFinish',width: 170,align: "center", formatter:function(a) {
	                    	 return formateToMinutes(a);
	                     }},
	                  	 {name: 'customerName',index: 'B.customerName',width: 130,align: "center"},
	                  	 {name: 'customerNo',index: 'B.customerNo',width: 170,align: "center"},
	                     {name: 'realLoanAmount',index: 'B.realLoanAmount',width: 130,align: "center"},
	                  	 {name: 'channelTypeDisplay',index: 'B.channelType',width: 130,align: "center"},
	               		 {name: 'dealerName',index: 'BDI.dealerName',width: 300,align: "center"},
	               		 {name: 'dealerLevelDisplay',index: 'BDI.dealerLevel',width: 130,align: "center"},
	            		 {name: 'orgName',index: 'BO.orgName',width: 130,align: "center"},
	            		 {name: 'salesmanName',index: 'S.name',width: 130,align: "center"},
	            		 {name: 'bankLoanDisplay',index: 'B.bankLoan',width: 300,align: "center"}
	                   ],
              mtype : "post",
              height: winHeight,
              width:winWidth,  
              autowidth: false,
              shrinkToFit: false,
              rowNum: 15,
	           rowList: [15, 30, 45],
              viewrecords: true,
              pager: "#pager_list_1",
              hidegrid: false,
              multiselect : false,
              altRows:true,
              sortname:'B.created',
              altclass:'someClass',
              ondblClickRow:function(rowId,v,e)
              {
            	  var rowData = $("#table_list_1").jqGrid("getRowData", rowId);
            	  var id = rowData.replaceId;
            	  
            	  $.dpAjax({
            		  url:'${basePath}/CwRemitCarController/checkLoanEditLock',
            		  data:{busiId:id},
            		  success:function(datas){
            			  var result = datas.result;
            			  if(result) {
            				  layer.msg('该订单正在申请修改贷款信息，不允许操作', {icon: 2});
            			  } else {
            				  $.dpAjax({
                        		  url:'${basePath}/CwRemitCarController/busiStatus',
                        		  data:{busiId:id},
                        		  success:function(datas){
                        			  var resultB = datas.result;
                        			  if(resultB) {
            			            	  layer.msg('正在进入，请稍后...',{icon: 16,shade: 0.01});
            			            	  window.location.href="${basePath}/CwRemitCarViewController/remitCarDetail?id=" + id;            	  
                        			  } else {
                        				  layer.msg('该订单已退贷，不能垫款', {icon: 2});
                        			  }
                        		  }
                        		  
                        	  })
            			  }
            		  }
            		  
            	  })
              },
              jsonReader : {
            	  root:"result.rows",
            	  page: "result.page",
            	  total: "result.total",
            	  records: "result.records",
            	  repeatitems: false,
            	  id: "replaceId"
              },
              loadComplete:function(datas){
            	  if (datas.flag == "100100") {
                      layer.msg("查询成功!", {icon: 6, time: 1000});
                      return;
                  }
            	  if(datas.flag == '100802') {
    				  top.location.href = thisLoginUrl;
    				  return;
    			  }

            	  layer.msg(datas.message, {icon: 2});
              }
	      });
	    }	    
	    
	    window.onresize = function()
	    {
	    	$("#table_list_1").setGridWidth($(window).width()-80);
	    }
	    
	    var query = function(start, end){
	    	var postData = $("#table_list_1").jqGrid("getGridParam", "postData");
	    	var data = {};
	    	data.customerName = document.getElementById('customerName').value || '';
	    	data.salesmanName = document.getElementById('salesmanName').value || '';
	    	if(start != null && typeof start != 'undefined') {
	    		document.getElementById('createOrderTimeStartDate').value = laydate.now(start);
	    		document.getElementById('createOrderTimeEndDate').value = laydate.now(end);
	    	}
	    	data.createOrderTimeStartDate = document.getElementById('createOrderTimeStartDate').value.trim();
	    	data.createOrderTimeEndDate = document.getElementById('createOrderTimeEndDate').value.trim();
	    	
	    	$.extend(postData, data);
	    	refresh();
	    }
	    
	    var refresh = function()
	    {
	    	$("#table_list_1").jqGrid("setGridParam", { search: true }).trigger("reloadGrid", [{ page: 1}]);
	    }
    </script>
</body>
</html>
